
uniform sampler2D iChannel0;
uniform sampler2D iChannel1;
uniform float speed;
vec2 center = vec2(1.0,1.0);

czm_material czm_getMaterial(czm_materialInput materialInput){
  czm_material material = czm_getDefaultMaterial(materialInput);
  vec2 v_st = materialInput.st; // 获取uv坐标
  
  float iTime = czm_frameNumber * speed / 150. ;
  vec2 uv = vec2( (center.x -v_st.x) ,  (center.y - v_st.y)) ;
  //Making the flow looks concave
  vec4 col = vec4(uv,0.6 + 0.5*sin(iTime),1.0);
  //Scale up UV
  uv *= 0.4;
  uv += col.xy*uv;
  //Make time slower
  float t = iTime * 0.015;
  //2 layers of speed, with some distortion
  vec4 c = texture2D(iChannel0,1.- fract(uv-t + col.xy * uv));
  vec4 d = texture2D(iChannel0,1.- fract((vec2(1)-uv) + t * 1.5-col.xy*uv) );
  c-=0.3;
  d-=0.3;
  
  vec4 f = texture2D(iChannel0,uv/100.0);
  
  float dist1 = length(c-f);
  float dist2 = length(d-f);

  vec4 result = vec4(min(dist1,dist2));

  vec4 g = texture2D(iChannel1,uv / vec2(dist1,dist2));
  float dist3 = dist1+ dist2;

  result = mix(result,g,result.r);
  material.alpha = pow(dist3 , 1.)  ;
  material.diffuse = result.rgb ;
  return material;
}